package com.hhss.qishi.mapper.system.provider;

import com.hhss.qishi.entity.system.WebLog;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.StringUtils;

/**
 * @Author :Administrator
 * @Description
 * @Date :2019-05-28 16:56.
 */
public class WebLogProvider {

	private static String SQL_ENTITY = "id, uuid, "
			+ "user_name AS userName, module_name AS moduleName, operate, description, normal, "
			+ "time_cost AS timeCost, url, parameter, ip, "
			+ "create_user AS createUser, create_time AS createTime, last_update_user AS lastUpdateUser, status, "
			+ "last_update_time AS lastUpdateTime, create_user AS createUser, last_update_user AS lastUpdateUser";

	private static String TABLE_NAME = "sys_weblog";

	/**
	 * 查找角色集合
	 * @param webLog
	 * @return
	 */
	public String getListSQL(final WebLog webLog) {
		return new SQL(){{
			SELECT(SQL_ENTITY);
			FROM(TABLE_NAME);
			WHERE("1=1");
			if(!StringUtils.isEmpty(webLog.getUserName())) {
				AND().WHERE("user_name like CONCAT('%',#{webLog.userName},'%')");
			}

		}}.toString();
	}
}
